package com.lwlk.zdk.service.CarService.impl;

import com.lwlk.zdk.mapper.pw.pwDriverMapper;
import com.lwlk.zdk.mapper.pw.pwVehicleMapper;
import com.lwlk.zdk.mapper.pw.pwPlatformAttentionMapper;
import com.lwlk.zdk.mapper.sys.sysEnterpriseMapper;
import com.lwlk.zdk.model.pw.pwDriver;
import com.lwlk.zdk.model.pw.pwPlatformAttention;
import com.lwlk.zdk.model.pw.pwVehicle;
import com.lwlk.zdk.model.sys.sysUser;
import com.lwlk.zdk.service.CarService.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CarServiceImpl implements CarService {

    @Autowired
    pwVehicleMapper vehicleMapper;
    @Autowired
    sysEnterpriseMapper sysEnterpriseMapper;
    @Autowired
    pwDriverMapper pwDriverMapper;
    @Autowired
    pwPlatformAttentionMapper pwPlatformAttentionMapper;

    @Override
    public int add(pwVehicle pwVehicle) {
        int i = vehicleMapper.insertSelective(pwVehicle);
        return i;
    }

    @Override
    public int update(pwVehicle pwVehicle) {
        int i = vehicleMapper.updateByPrimaryKeySelective(pwVehicle);
        return i;
    }

    @Override
    public int delete(Integer vehicleId) {
        int i = vehicleMapper.deleteByPrimaryKey(vehicleId);
        return i;
    }

    @Override
    public List selectByPlatformId(Integer platformId) {
        List<Map<String,Object>> vehicle=vehicleMapper.selectByPlatformId(platformId);
        return vehicle;
    }

    @Override
    public List<Map<String, Object>> selectDimByPlatformId(Integer platformId, String vehicleNumber, String carType, String enterprise, String networkState, String vehicleLicenseColor) {

        List<Map<String,Object>> vehicle=vehicleMapper.selectDimByPlatformId(platformId,vehicleNumber,carType,enterprise,networkState,vehicleLicenseColor);
        return vehicle;
    }

    @Override
    public List<Map<String, Object>> selectDetail(Integer vehicleId) {

        List<Map<String,Object>>vehicleDetail=vehicleMapper.selectVehicleDetail(vehicleId);

        return vehicleDetail;
    }

    @Override
    public int selectRegularBus() {
        int regularBusSum=vehicleMapper.selectRegularBus();
        return regularBusSum;
    }

    @Override
    public int selectCharteredBus() {
        int charteredBus=vehicleMapper.selectCharteredBus();
        return charteredBus;
    }

    @Override
    public int selectDangerousGoods() {
        int DangerousGoods=vehicleMapper.selectDangerousGoods();
        return DangerousGoods;
    }

    @Override
    public int selectJoinPlatform(String areaCode) {
        int count=sysEnterpriseMapper.selectJoinPlatform(areaCode);
        return count;
    }

    @Override
    public int selectEnterprise() {
        int count=sysEnterpriseMapper.selectEnterpriseCount();
        return count;
    }

    @Override
    public int selectRegularEnterprise(String areaCode) {
        int count=sysEnterpriseMapper.selectRegularEnterprise(areaCode);
        return count;
    }

    @Override
    public int selectCharteredEnterprise(String areaCode) {
        int count=sysEnterpriseMapper.selectCharteredEnterprise(areaCode);
        return count;
    }

    @Override
    public int selectDangerousGoodsEnterprise(String areaCode) {
        int count=sysEnterpriseMapper.selectDangerousGoodsEnterprise(areaCode);
        return count;
    }

    @Override
    public List<sysUser> selectPlatformMessage(Integer vehicleId) {
        List<sysUser>vehicleMessage=vehicleMapper.selectPlatformMessage(vehicleId);
        return vehicleMessage;
    }

    @Override
    public List<pwVehicle> selectVehicleMessage(String vehicleNumber) {
        List<pwVehicle>pwVehicleList=vehicleMapper.selectVehicleMessage(vehicleNumber);
        return pwVehicleList;
    }

    @Override
    public pwDriver selectDriverMessage(String vehicleNumber) {
        pwDriver pwDriver=pwDriverMapper.selectDriverMessage(vehicleNumber);
        return pwDriver;
    }

    @Override
    public List<Map<String, Object>> selectEnterpriseMessage(String vehicleNumber) {
        List<Map<String,Object>>enterpriseMessage=vehicleMapper.selectEnterpriseMessage(vehicleNumber);
        return enterpriseMessage;
    }

    @Override
    public List<pwPlatformAttention> selectPlatformAttention(Integer platformId) {
        List<pwPlatformAttention>pwPlatformAttentionList=pwPlatformAttentionMapper.selectPlatformAttention(platformId);
        return pwPlatformAttentionList;
    }

    @Override
    public List<Map<String, Object>> selectVehicleIndustry(String industry) {
        List<Map<String,Object>>vehicleIndustry=vehicleMapper.selectVehicleIndustry(industry);
        return vehicleIndustry;
    }


    @Override
    public List<Map<String, Object>> selectVehicleIndustryAndIndustry(String isOnline, String industry) {
        List<Map<String,Object>>vehicleIndustryAndIndustry=vehicleMapper.selectVehicleIndustryAndIndustry(isOnline,industry);
        return vehicleIndustryAndIndustry;
    }

    @Override
    public int platformAttentionAdd(Integer platformId, String vehicleNumber,Integer vId,String sim) {
        pwPlatformAttention pwPlatformAttention=new pwPlatformAttention();
        pwPlatformAttention.setPlatformId(platformId);
        pwPlatformAttention.setVehicleNumber(vehicleNumber);
        pwPlatformAttention.setvId(vId);
        pwPlatformAttention.setSim(sim);
        int i=pwPlatformAttentionMapper.insertSelective(pwPlatformAttention);
        return i;
    }

    @Override
    public int platformAttentionDelete(Integer id) {
        int i=pwPlatformAttentionMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public List selectPlatformIds(Integer platformId) {
        List vehicleIds=vehicleMapper.selectVehicleIds(platformId);
        return vehicleIds;
    }

    @Override
    public List<Map<String, Object>> selectPlatformVehicleAll(Integer platformId) {
        List<Map<String,Object>>platformVehicle=vehicleMapper.selectByPlatformId(platformId);
        return platformVehicle;
    }

    @Override
    public List<Map<String, Object>> selectVehicleNumber() {
        List<Map<String,Object>>vehicleNumber=vehicleMapper.selectVehicleNumber();
        return vehicleNumber;
    }

    @Override
    public String selectVehicleName(int vId) {
        String vName=vehicleMapper.selectVehicleName(vId);
        return vName;
    }

    @Override
    public int selectManyVehicleNumber(String vehicleNumber) {
        int i=vehicleMapper.selectManyVehicleNumber(vehicleNumber);
        return i;
    }

    @Override
    public int selectByVehicleId(Integer vId) {
        int i=pwPlatformAttentionMapper.selectByVehicleId(vId);
        return i;
    }


}
